package org.jeecg.modules.utils;

import org.gavaghan.geodesy.Ellipsoid;
import org.gavaghan.geodesy.GeodeticCalculator;
import org.gavaghan.geodesy.GeodeticCurve;
import org.gavaghan.geodesy.GlobalCoordinates;
import org.springframework.stereotype.Component;

import java.text.DecimalFormat;

/**
 * 月月鸟
 */
@Component
public class CaculateDistanceUtils {


    /**
     * 计算时速
     * */
    public static double getSpeed(double distance,long time){
        //米
        int newDistance = (int) distance;
        //秒
        int newTime = (int) time/1000;
        int dh = (newDistance / newTime)*60*60/1000;
        return dh ;
    }
    /**
     * 获取 a - b 距离
     * */
    public static double getDistanceMeter(GlobalCoordinates gpsFrom, GlobalCoordinates gpsTo, Ellipsoid ellipsoid){

        //创建GeodeticCalculator，调用计算方法，传入坐标系、经纬度用于计算距离
        GeodeticCurve geoCurve = new GeodeticCalculator().calculateGeodeticCurve(ellipsoid, gpsFrom, gpsTo);

        return geoCurve.getEllipsoidalDistance();
    }
}
